@extends('admin.layout.layout', ['row' => @$page])

@section('contain')


    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions"></div>
        </div>

        <div class="filter-wrapper">
            <form action="/{{ request()->path() }}/" class="form-inline filter-form">
                <div class=" input-group mb-3 custom-control-inline">
                    <input type="text" class="form-control s-input" name="value" value="{{ request()->input('value') }}" placeholder="{{ ts('vrr1') }}" style="width: 480px;">
                </div>

                <div class="input-group mb-3 custom-control-inline">
                    <select name="status" class="form-control">
                        <option value="">{{ ts('select').' '.ts('status') }}</option>
                        <option value="0" {{ request()->input('status') !== null && request()->input('status') == 0 ? 'selected' : '' }}>{{ ts('DS1') }}</option>
                        <option value="1" {{ request()->input('status') == 1 ? 'selected' : '' }}>{{ ts('DS2') }}</option>
                        <option value="2" {{ request()->input('status') == 2 ? 'selected' : '' }}>{{ ts('DS3') }}</option>
                    </select>
                </div>

                <x-flatpickr-date-range label="{{ ts('fqsj') }}"></x-flatpickr-date-range>
                <div class="mb-3">
                    <button class="btn btn-primary">{{ ts('SEARCH') }}</button>
                    <a href="/{{ request()->path() }}/" class="btn btn-warning">{{ ts('RESET') }}</a>
                </div>

            </form>
        </div>

        <div>
            <table class="table text-nowrap bt-table d-none">
                <thead>
                <tr class="order_column">
                    {{--<th></th>--}}
                    <th>{{ ts('sequence') }}</th>
                    <th>{{ ts('rollnumber') }}</th>
                    <th>{{ ts('ysdmc') }}</th>
                    <th>{{ ts('ygmsmc') }}</th>
                    <th>{{ ts('FQR') }}</th>
                    <th>{{ ts('FQSJ') }}</th>
                    <th>{{ ts('status') }}</th>
                    <th>{{ ts('OPERATIONS') }}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $k => $v)
                    @if(session('hightlight') && session('hightlight.type')=='precut-return' && session('hightlight.id')==$v->id)
                        <tr class="item-list table-warning">
                    @else
                        <tr class="item-list">
                            @endif
                            {{--<td class="text-center">
                                <input type="checkbox" class="warranty_icheck icheck_input" name="ids[]" value="{{ $v->id }}">
                            </td>--}}
                            <td class="text-center">
                                {{ @$data->firstItem()+$k }}
                            </td>
                            <td>
                                <a href="/admin/rolls/{{ @$v->rid }}">{{ @$v->roll_number }}</a>
                            </td>
                            <td>
                                {{ @$v->ysdmc }}
                            </td>
                            <td>
                                {{ @$v->ygmsmc }}
                            </td>
                            <td>
                                {{ @$v->fqr }}
                            </td>
                            <td>
                                {{ fdate2(@$v->created_at) }}
                            </td>
                            <td>
                                {{ ts('STA'.(int)@$v->status) }}
                            </td>

                            <td>
                                <a class="btn btn-success btn-sm" href='/{{ request()->path() }}/{{ $v->id }}'>{{ ts('VIEW') }}</a>
                            </td>
                        </tr>
                        @endforeach
                </tbody>
            </table>

            <div class="row my-3">
                {{--<div class="col-auto">
                    <label style="cursor: pointer"><input type="checkbox" class="icheck_all" data-ele=".warranty_icheck"><span class="ml-2">{{ ts('SELECTALL') }}</span></label>
                    @if(session('admin.user_type') == 1)
                        <span class="btn btn-primary ml-3" onclick="deleteAlliCheck('.warranty_icheck', '/admin/precut/deletes')">{{ ts('delete') }}</span>
                    @endif
                </div>--}}
                <div class="col">
                    {{ $data->appends(request()->input())->links() }}
                </div>
            </div>
        </div>

    </div>


@endsection



@section('script')
    <script>
        $('body').on('change', '[name="sdid"]', function () {
            var val=$(this).val();
            var $that = $(this)
            request.get('/admin/ajax/getUsers', {
                params: {
                    t: 'd',
                    user_id: val
                }
            })
                .then( function(d) {
                    var data = d.data
                    $('.portlet select[name="user_id"]').empty().append(makeSelectOptionsOnly(data))
                })
                .catch(function (d) {
                    toastr.error(d.msg)
                })
        })
        $(document).ready(function () {
            if ($('[name="sdid"]').length >=1 ) {
                request.get('/admin/ajax/getUsers', {
                    params: {
                        t: 'd',
                        user_id: $('[name="sdid"]').val()
                    }
                })
                    .then( function(d) {
                        var data = d.data
                        $('.portlet select[name="user_id"]').empty().append(makeSelectOptionsOnly(data))
                    })
                    .catch(function (d) {
                        toastr.error(d.msg)
                    })
            }

            $('.table.bt-table').bootstrapTable({
                /*fixedColumns: true,
                fixedNumber: 1,
                fixedRightNumber: 1,*/
            }).removeClass('d-none')
        })
        function oAP (id, precut_id) {
            $('#precutAssign').find('[name="id"]').val(id)
            $('#precutAssign').find('[name="precut_id"]').val(precut_id)
            $('#precutAssign').modal();
        }
    </script>
@endsection